﻿using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Xml.Serialization;
using System.Collections.Generic;

namespace ConvergensSettings
{
    public class CDCOXMLSettings
    {
        private Configuration config = new Configuration();

        [XmlElement("Configuration")]
        public Configuration Config
        { get { return config; } set { config = value; } }

        public class Configuration
        {
            private Domino domino = new Domino();

            [XmlElement("Domino")]
            public Domino Domino
            { get { return domino; } set { domino = value; } }

            private MailItem mailItem = new MailItem();
            [XmlElement("MailItem")]
            public MailItem MailItem
            { get { return mailItem; } set { mailItem = value; } }

            private ReportItem reportItem = new ReportItem();
            [XmlElement("ReportItem")]
            public ReportItem ReportItem
            { get { return reportItem; } set { reportItem = value; } }

            private MeetingItem meetingItem = new MeetingItem();
            [XmlElement("MeetingItem")]
            public MeetingItem MeetingItem
            { get { return meetingItem; } set { meetingItem = value; } }

            private JournalizeSingle journalizeSingle = new JournalizeSingle();
            [XmlElement("JournalizeSingle")]
            public JournalizeSingle JournalizeSingle
            { get { return journalizeSingle; } set { journalizeSingle = value; } }

            private JournalizeMulti journalizeMulti = new JournalizeMulti();
            [XmlElement("JournalizeMulti")]
            public JournalizeMulti JournalizeMulti
            { get { return journalizeMulti; } set { journalizeMulti = value; } }

        }

        public class Domino
        {
            private string sdhServerName = string.Empty;

            [XmlElement("SDHServerName")]
            public string SDHServerName
            { get { return sdhServerName; } set { sdhServerName = value; } }

            private string databasePath = string.Empty;

            [XmlElement("DatabasePath")]
            public string DatabasePath
            { get { return databasePath; } set { databasePath = value; } }

            private string mailServerName = string.Empty;

            [XmlElement("MailServerName")]
            public string MailServerName
            { get { return mailServerName; } set { mailServerName = value; } }

            private string journalizeToUserMailDb = string.Empty;

            [XmlElement("JournalizeToUserMailDb")]
            public string JournalizeToUserMailDb
            { get { return journalizeToUserMailDb; } set { journalizeToUserMailDb = value; } }

            private SDHAgents sDHAgents = new SDHAgents();

        }

        public class MailItem
        {
            private string x_oSentOn = string.Empty;

            [XmlElement("SentOn")]
            public string X_oSentOn
            { get { return x_oSentOn; } set { x_oSentOn = value; } }

            private string x_oSenderName = string.Empty;

            [XmlElement("SenderName")]
            public string X_oSenderName
            { get { return x_oSenderName; } set { x_oSenderName = value; } }

            private string x_oSenderEmailAddress = string.Empty;

            [XmlElement("SenderEmailAddress")]
            public string X_oSenderEmailAddress
            { get { return x_oSenderEmailAddress; } set { x_oSenderEmailAddress = value; } }

            private string x_oSentOnBehalfOfName = string.Empty;

            [XmlElement("SentOnBehalfOfName")]
            public string X_oSentOnBehalfOfName
            { get { return x_oSentOnBehalfOfName; } set { x_oSentOnBehalfOfName = value; } }

            private string x_oReceivedTime = string.Empty;

            [XmlElement("ReceivedTime")]
            public string X_oReceivedTime
            { get { return x_oReceivedTime; } set { x_oReceivedTime = value; } }

            private string x_oReceivedByName = string.Empty;

            [XmlElement("ReceivedByName")]
            public string X_oReceivedByName
            { get { return x_oReceivedByName; } set { x_oReceivedByName = value; } }

            private string x_oReceivedOnBehalfOfName = string.Empty;

            [XmlElement("ReceivedOnBehalfOfName")]
            public string X_oReceivedOnBehalfOfName
            { get { return x_oReceivedOnBehalfOfName; } set { x_oReceivedOnBehalfOfName = value; } }

            private string x_oReplyRecipientNames = string.Empty;

            [XmlElement("ReplyRecipientNames")]
            public string X_oReplyRecipientNames
            { get { return x_oReplyRecipientNames; } set { x_oReplyRecipientNames = value; } }

            private string x_oSubject = string.Empty;

            [XmlElement("Subject")]
            public string X_oSubject
            { get { return x_oSubject; } set { x_oSubject = value; } }

            private string x_oBodyFormat = string.Empty;

            [XmlElement("BodyFormat")]
            public string X_oBodyFormat
            { get { return x_oBodyFormat; } set { x_oBodyFormat = value; } }

            private string x_oEntryID = string.Empty;

            [XmlElement("EntryID")]
            public string X_oEntryID
            { get { return x_oEntryID; } set { x_oEntryID = value; } }

            private string x_oResolvedSenderEmailAdress = string.Empty;

            [XmlElement("ResolvedSenderEmailAdress")]
            public string X_oResolvedSenderEmailAdress
            { get { return x_oResolvedSenderEmailAdress; } set { x_oResolvedSenderEmailAdress = value; } }

            private string x_oTo = string.Empty;

            [XmlElement("To")]
            public string X_oTo
            { get { return x_oTo; } set { x_oTo = value; } }

            private string x_oCC = string.Empty;

            [XmlElement("CC")]
            public string X_oCC
            { get { return x_oCC; } set { x_oCC = value; } }

            private string x_oBCC = string.Empty;

            [XmlElement("BCC")]
            public string X_oBCC
            { get { return x_oBCC; } set { x_oBCC = value; } }

            private string x_oBody = string.Empty;

            [XmlElement("Body")]
            public string X_oBody
            { get { return x_oBody; } set { x_oBody = value; } }

            private string x_oEML = string.Empty;

            [XmlElement("EMLBody")]
            public string X_oEML
            { get { return x_oEML; } set { x_oEML = value; } }

            private string x_oMSG = string.Empty;

            [XmlElement("MSGBody")]
            public string X_oMSG
            { get { return x_oMSG; } set { x_oMSG = value; } }

            private string form = string.Empty;
            [XmlElement("Form")]
            public string Form
            { get { return form; } set { form = value; } }

            private string saveAsType = string.Empty;
            [XmlElement("SaveAsType")]
            public string SaveAsType
            { get { return saveAsType; } set { saveAsType = value; } }

            private string conversationID = string.Empty;
            [XmlElement("ConversationID")]
            public string ConversationID
            { get { return conversationID; } set { conversationID = value; } }
        }

        public class ReportItem
        {
            private string rptItm_EntryID = string.Empty;
            [XmlElement("EntryID")]
            public string RptItm_EntryID 
            { get { return rptItm_EntryID; } set { rptItm_EntryID = value; } }

            private string rptItm_Subject = string.Empty;
            [XmlElement("Subject")]
            public string RptItm_Subject 
            { get { return rptItm_Subject; } set { rptItm_Subject = value; } }

            private string rptItm_CreationTime = string.Empty;
            [XmlElement("CreationTime")]
            public string RptItm_CreationTime 
            { get { return rptItm_CreationTime; } set { rptItm_CreationTime = value; } }

            private string rptItm_To = string.Empty;
            [XmlElement("To")]
            public string RptItm_To
            { get { return rptItm_To; } set { rptItm_To = value; } }

            private string rptItm_CC = string.Empty;
            [XmlElement("CC")]
            public string RptItm_CC
            { get { return rptItm_CC; } set { rptItm_CC = value; } }

            private string rptItm_BCC = string.Empty;
            [XmlElement("BCC")]
            public string RptItm_BCC 
            { get { return rptItm_BCC; } set { rptItm_BCC = value; } }

            private string rptItm_Body = string.Empty;
            [XmlElement("Body")]
            public string RptItm_Body 
            { get { return rptItm_Body; } set { rptItm_Body = value; } }

            private string rptItm_EMLBody = string.Empty;
            [XmlElement("EMLBody")]
            public string RptItm_EMLBody 
            { get { return rptItm_EMLBody; } set { rptItm_EMLBody = value; } }

            private string rptItm_MSGBody = string.Empty;
            [XmlElement("MSGBody")]
            public string RptItm_MSGBody 
            { get { return rptItm_MSGBody; } set { rptItm_MSGBody = value; } }

            private string rptItm_Form = string.Empty;
            [XmlElement("Form")]
            public string RptItm_Form 
            { get { return rptItm_Form; } set { rptItm_Form = value; } }

            private string rptItm_SaveAsType = string.Empty;
            [XmlElement("SaveAsType")]
            public string RptItm_SaveAsType 
            { get { return rptItm_SaveAsType; } set { rptItm_SaveAsType = value; } }

            private string rptItm_From = string.Empty;
            [XmlElement("From")]
            public string RptItm_From
            { get { return rptItm_From; } set { rptItm_From = value; } }

            private string rptItm_conversationID = string.Empty;
            [XmlElement("ConversationID")]
            public string RptItm_ConversationID
            { get { return rptItm_conversationID; } set { rptItm_conversationID = value; } }

            private string rptItm_receivedByName = string.Empty;
            [XmlElement("ReceivedByName")]
            public string RptItm_ReceivedByName
            { get { return rptItm_receivedByName; } set { rptItm_receivedByName = value; } }

            private string rptItm_ReceivedOnBehalfOfName = string.Empty;
            [XmlElement("ReceivedOnBehalfOfName")]
            public string RptItm_ReceivedOnBehalfOfName
            { get { return rptItm_ReceivedOnBehalfOfName; } set { rptItm_ReceivedOnBehalfOfName = value; } }

            private string rptItm_replyRecipientNames = string.Empty;
            [XmlElement("ReplyRecipientNames")]
            public string RptItm_ReplyRecipientNames
            { get { return rptItm_replyRecipientNames; } set { rptItm_replyRecipientNames = value; } }

            private string rptItm_resolvedSenderEmailAdress = string.Empty;
            [XmlElement("ResolvedSenderEmailAdress")]
            public string RptItm_ResolvedSenderEmailAdress
            { get { return rptItm_resolvedSenderEmailAdress; } set { rptItm_resolvedSenderEmailAdress = value; } }

            private string rptItm_renderEmailAddress = string.Empty;
            [XmlElement("SenderEmailAddress")]
            public string RptItm_SenderEmailAddress
            { get { return rptItm_renderEmailAddress; } set { rptItm_renderEmailAddress = value; } }

            private string rptItm_senderName = string.Empty;
            [XmlElement("SenderName")]
            public string RptItm_SenderName
            { get { return rptItm_senderName; } set { rptItm_senderName = value; } }

            private string rptItm_sentOnBehalfOfName = string.Empty;
            [XmlElement("SentOnBehalfOfName")]
            public string RptItm_SentOnBehalfOfName
            { get { return rptItm_sentOnBehalfOfName; } set { rptItm_sentOnBehalfOfName = value; } }
        }

        public class MeetingItem
        {
            private string mtgItm_EntryID = string.Empty;
            [XmlElement("EntryID")]
            public string MtgItm_EntryID
            { get { return mtgItm_EntryID; } set { mtgItm_EntryID = value; } }

            private string mtgItm_Subject = string.Empty;
            [XmlElement("Subject")]
            public string MtgItm_Subject
            { get { return mtgItm_Subject; } set { mtgItm_Subject = value; } }

            private string mtgItm_CreationTime = string.Empty;
            [XmlElement("CreationTime")]
            public string MtgItm_CreationTime
            { get { return mtgItm_CreationTime; } set { mtgItm_CreationTime = value; } }

            private string mtgItm_To = string.Empty;
            [XmlElement("To")]
            public string MtgItm_To
            { get { return mtgItm_To; } set { mtgItm_To = value; } }

            private string mtgItm_CC = string.Empty;
            [XmlElement("CC")]
            public string MtgItm_CC
            { get { return mtgItm_CC; } set { mtgItm_CC = value; } }

            private string mtgItm_BCC = string.Empty;
            [XmlElement("BCC")]
            public string MtgItm_BCC
            { get { return mtgItm_BCC; } set { mtgItm_BCC = value; } }

            private string mtgItm_Body = string.Empty;
            [XmlElement("Body")]
            public string MtgItm_Body
            { get { return mtgItm_Body; } set { mtgItm_Body = value; } }

            private string mtgItm_EMLBody = string.Empty;
            [XmlElement("EMLBody")]
            public string MtgItm_EMLBody
            { get { return mtgItm_EMLBody; } set { mtgItm_EMLBody = value; } }

            private string mtgItm_MSGBody = string.Empty;
            [XmlElement("MSGBody")]
            public string MtgItm_MSGBody
            { get { return mtgItm_MSGBody; } set { mtgItm_MSGBody = value; } }

            private string mtgItm_Form = string.Empty;
            [XmlElement("Form")]
            public string MtgItm_Form
            { get { return mtgItm_Form; } set { mtgItm_Form = value; } }

            private string mtgItm_SaveAsType = string.Empty;
            [XmlElement("SaveAsType")]
            public string MtgItm_SaveAsType
            { get { return mtgItm_SaveAsType; } set { mtgItm_SaveAsType = value; } }

            private string mtgItm_From = string.Empty;
            [XmlElement("From")]
            public string MtgItm_From
            { get { return mtgItm_From; } set { mtgItm_From = value; } }

            private string mtgItm_conversationID = string.Empty;
            [XmlElement("ConversationID")]
            public string MtgItm_ConversationID
            { get { return mtgItm_conversationID; } set { mtgItm_conversationID = value; } }

            private string mtgItm_receivedByName = string.Empty;
            [XmlElement("ReceivedByName")]
            public string MtgItm_ReceivedByName
            { get { return mtgItm_receivedByName; } set { mtgItm_receivedByName = value; } }

            private string mtgItm_ReceivedOnBehalfOfName = string.Empty;
            [XmlElement("ReceivedOnBehalfOfName")]
            public string MtgItm_ReceivedOnBehalfOfName
            { get { return mtgItm_ReceivedOnBehalfOfName; } set { mtgItm_ReceivedOnBehalfOfName = value; } }

            private string mtgItm_replyRecipientNames = string.Empty;
            [XmlElement("ReplyRecipientNames")]
            public string MtgItm_ReplyRecipientNames
            { get { return mtgItm_replyRecipientNames; } set { mtgItm_replyRecipientNames = value; } }

            private string mtgItm_resolvedSenderEmailAdress = string.Empty;
            [XmlElement("ResolvedSenderEmailAdress")]
            public string MtgItm_ResolvedSenderEmailAdress
            { get { return mtgItm_resolvedSenderEmailAdress; } set { mtgItm_resolvedSenderEmailAdress = value; } }

            private string mtgItm_renderEmailAddress = string.Empty;
            [XmlElement("SenderEmailAddress")]
            public string MtgItm_SenderEmailAddress
            { get { return mtgItm_renderEmailAddress; } set { mtgItm_renderEmailAddress = value; } }

            private string mtgItm_senderName = string.Empty;
            [XmlElement("SenderName")]
            public string MtgItm_SenderName
            { get { return mtgItm_senderName; } set { mtgItm_senderName = value; } }

            private string mtgItm_sentOnBehalfOfName = string.Empty;
            [XmlElement("SentOnBehalfOfName")]
            public string MtgItm_SentOnBehalfOfName
            { get { return mtgItm_sentOnBehalfOfName; } set { mtgItm_sentOnBehalfOfName = value; } }
        }

        public class JournalizeSingle
        {
            private string jnalSgl_cbSDH = string.Empty;
            [XmlElement("cbSDH")]
            public string JnalSgl_cbSDH
            { get { return jnalSgl_cbSDH; } set { jnalSgl_cbSDH = value; } }

            private string jnalSgl_tbCaseNum = string.Empty;
            [XmlElement("tbCaseNum")]
            public string JnalSgl_tbCaseNum { get { return jnalSgl_tbCaseNum; } set { jnalSgl_tbCaseNum = value; } }

            private string jnalSgl_lbtitle = string.Empty;
            [XmlElement("lbtitle")]
            public string JnalSgl_lbtitle
            { get { return jnalSgl_lbtitle; } set { jnalSgl_lbtitle = value; } }

            private string jnalSgl_rbMustReply = string.Empty;
            [XmlElement("rbMustReply")]
            public string JnalSgl_rbMustReply
            { get { return jnalSgl_rbMustReply; } set { jnalSgl_rbMustReply = value; } }

            private string jnalSgl_tbSeqNum = string.Empty;
            [XmlElement("tbSeqNum")]
            public string JnalSgl_tbSeqNum
            { get { return jnalSgl_tbSeqNum; } set { jnalSgl_tbSeqNum = value; } }

            private string jnalSgl_cbRplyReq = string.Empty;
            [XmlElement("cbRplyReq")]
            public string JnalSgl_cbRplyReq
            { get { return jnalSgl_cbRplyReq; } set { jnalSgl_cbRplyReq = value; } }

            private string jnalSgl_cbCaseOfr = string.Empty;
            [XmlElement("cbCaseOfr")]
            public string JnalSgl_cbCaseOfr
            { get { return jnalSgl_cbCaseOfr; } set { jnalSgl_cbCaseOfr = value; } }

            private string jnalSgl_lbMailRightSelected = string.Empty;
            [XmlElement("lbMailRightSelected")]
            public string JnalSgl_lbMailRightSelected
            { get { return jnalSgl_lbMailRightSelected; } set { jnalSgl_lbMailRightSelected = value; } }

            private string jnalSgl_tbDocName = string.Empty;
            [XmlElement("tbDocName")]
            public string JnalSgl_tbDocName
            { get { return jnalSgl_tbDocName; } set { jnalSgl_tbDocName = value; } }

            private string jnalSgl_tbRemarks = string.Empty;
            [XmlElement("tbRemarks")]
            public string JnalSgl_tbRemarks
            { get { return jnalSgl_tbRemarks; } set { jnalSgl_tbRemarks = value; } }

            private string jnalSgl_cbCaseParts = string.Empty;
            [XmlElement("cbCaseParts")]
            public string JnalSgl_cbCaseParts
            { get { return jnalSgl_cbCaseParts; } set { jnalSgl_cbCaseParts = value; } }

            private string jnalSgl_cbFreeCat = string.Empty;
            [XmlElement("cbFreeCat")]
            public string JnalSgl_cbFreeCat
            { get { return jnalSgl_cbFreeCat; } set { jnalSgl_cbFreeCat = value; } }

            private string jnalSgl_lbCaseArea = string.Empty;
            [XmlElement("lbCaseArea")]
            public string JnalSgl_lbCaseArea
            { get { return jnalSgl_lbCaseArea; } set { jnalSgl_lbCaseArea = value; } }

            private string jnalSgl_lbEdction = string.Empty;
            [XmlElement("lbEdction")]
            public string JnalSgl_lbEdction
            { get { return jnalSgl_lbEdction; } set { jnalSgl_lbEdction = value; } }

            private string jnalSgl_lbInstitution = string.Empty;
            [XmlElement("lbInstitution")]
            public string JnalSgl_lbInstitution
            { get { return jnalSgl_lbInstitution; } set { jnalSgl_lbInstitution = value; } }

            private string jnalSgl_lbLeglAspcts = string.Empty;
            [XmlElement("lbLeglAspcts")]
            public string JnalSgl_lbLeglAspcts
            { get { return jnalSgl_lbLeglAspcts; } set { jnalSgl_lbLeglAspcts = value; } }

            private string jnalSgl_lbEcoAspcts = string.Empty;
            [XmlElement("lbEcoAspcts")]
            public string JnalSgl_lbEcoAspcts
            { get { return jnalSgl_lbEcoAspcts; } set { jnalSgl_lbEcoAspcts = value; } }

        }

        public class JournalizeMulti
        {
        }

        public class SDHAgents
        {
            private ControlCheckAgent controlCheckAgent = new ControlCheckAgent();
            private PostJournalizeAgent postJournalizeAgent = new PostJournalizeAgent();

        }

        public class ControlCheckAgent
        {
            private string controlCheckAgent = string.Empty;
            [XmlElement("ControlCheckAgent")]
            public string ControlCheckAgentValue
            { get { return controlCheckAgent; } set { controlCheckAgent = value; } }

            private AgentName agentName = new AgentName();
            private ControlField controlField = new ControlField();

        }

        public class PostJournalizeAgent
        {
            private string postJournalizeAgent = string.Empty;
            [XmlElement("PostJournalizeAgent")]
            public string PostJournalizeAgentValue
            { get { return postJournalizeAgent; } set { postJournalizeAgent = value; } }
        }

        public class AgentName
        {
            private string agentName = string.Empty;
            [XmlElement("AgentName")]
            public string AgentNameValue
            { get { return agentName; } set { agentName = value; } }
        }

        public class ControlField
        {
            private string controlField = string.Empty;
            [XmlElement("ControlField")]
            public string ControlFieldValue
            { get { return controlField; } set { controlField = value; } }
        }


        public static void SerializeToXML(TextWriter textWriter, Configuration configuration)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
            serializer.Serialize(textWriter, configuration);
        }

        public static Configuration DeserializeFromXML(TextReader textReader)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(Configuration));
            return (Configuration)deserializer.Deserialize(textReader);
        }
    }
}
